home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1529 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: theory.lcs.mit.edu!wald
  2. From: wald@theory.lcs.mit.edu (David Wald)
  3. Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.lang.eiffel
  4. Subject: Re: type checking in C++ was Re: Hungarian notation
  5. Followup-To: comp.lang.c++
  6. Date: 11 Jan 1996 15:35:16 GMT
  7. Organization: Theory of Computation, LCS, MIT
  8. Message-ID: <WALD.96Jan11103517@woodpecker.lcs.mit.edu>
  9. References: <4cf8hf$8fe@hopi.gate.net> <DKoBrn.CHs@falcon.daytonoh.attgis.com>
  10.     <4d1j37$ge8@stc06.ctd.ornl.gov> <4d2dqq$4lq@news.uni-c.dk>
  11. NNTP-Posting-Host: woodpecker.lcs.mit.edu
  12. In-reply-to: Peter Juhl's message of 11 Jan 1996 07:22:02 GMT
  13.  
  14. In article <4d2dqq$4lq@news.uni-c.dk> Peter Juhl
  15. <etiaseti@inet.uni-c.dk> writes:
  16. >mbk@jt3ws1.etd.ornl.gov (Kennel) wrote:
  17. >>Dick Menninger (Dick.Menninger@DaytonOH.ATTGIS.COM) wrote:
  18. >>> Imbedding type information in a name had some utility
  19. >>> in the older C environments with the weak type checking
  20.  
  21. >>At one point something like this could be a problem.  It it still?
  22. >>
  23. >>function(Type *p) {
  24. >>
  25. >>// One of this may silently crash or do bad things.  Both typecheck. 
  26. >>
  27. >>//    delete p;
  28. >>//    delete [] p; 
  29. >>
  30. >>}
  31. >>
  32.  
  33. >This has not been a problem for years, delete p , is the way 
  34. >things work.
  35.  
  36. If you're talking about C++, you're mistaken; you don't know from the
  37. type of p whether *p was allocated with new or new[], and you get
  38. undefined behavior if you use the wrong delete.  You may be thinking
  39. of the numeric argument to delete[], as in "delete[5] p", which is
  40. indeed obsolete, but the delete vs. delete[] problem still exists.
  41.  
  42. This is described briefly in questions 37 & 38 of the comp.lang.c++
  43. Frequently Asked Questions list, and at greater length in sections
  44. [expr.new] and [expr.delete] of the draft ANSI standard.
  45.  
  46. -David
  47. -- 
  48. ============================================================================
  49. David Wald      http://theory.lcs.mit.edu/~wald/     wald@theory.lcs.mit.edu
  50. ============================================================================
  51.